import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useDeliveryStore = defineStore('delivery', () => {
  const deliveryList = ref<Delivery[]>([])
  const delivery = ref<Delivery>({
    no: 0,
    orderId: "",
    clientName: "",
    clientCode: "",
    skuId: 0,
    skuName: "",
    skuBrand: "",
    internalBrand: "",
    specification: "",
    unit: "",
    shouldDeliver: null,
    oweDeliver: null,
    inventoryPcs: null,
    inventoryWeight: null,
    thisDeliver: null,
    deliverDt: "",
    amount: null,
    quantity: null,
    weight: null,
    unitPrice: null,
    checked: null,
    thisDeliverWeight: null,
    byQuantity: "",
    thisDeliverAmount: null
  })
  const resetDelivery = (formRef) => {
    formRef.value.resetFields()
    delivery.value.no = 0
    delivery.value.orderId = ""
    delivery.value.clientCode = ""
    delivery.value.inventoryPcs = null
    delivery.value.inventoryWeight = null
    delivery.value.shouldDeliver = null
    delivery.value.oweDeliver = null
    delivery.value.thisDeliver = null
    delivery.value.deliverDt = ""
  }

  return {
    deliveryList,
    delivery,
    resetDelivery
  }
})

interface Delivery {
    no: number,
    orderId: string,
    clientName: string,
    clientCode: string,
    skuId: number,
    skuName: string,
    skuBrand: string,
    internalBrand: string,
    specification: string,
    unit: string,
    shouldDeliver: number,
    oweDeliver: number,
    inventoryPcs: number,
    inventoryWeight: number,
    thisDeliver: number,
    deliverDt: string,
    amount: number,
    quantity: number,
    weight: number,
    unitPrice: number,
    checked: number,
    thisDeliverWeight: number,
    byQuantity: string,
    thisDeliverAmount: number
}